package com.gxnzd.communityelderly.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxnzd.communityelderly.commom.R;
import com.gxnzd.communityelderly.entity.Employee;
import com.gxnzd.communityelderly.entity.Forum;
import com.gxnzd.communityelderly.service.ForumService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ForumController
 * Package: com.gxnzd.communityelderly.controller
 * Description:
 *
 * @Author 胡海峰
 * @Create 2024/11/17 16:45
 * @Version 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("/forum")
public class ForumController {

    @Resource
    private ForumService forumService;

    //添加帖子
    @PostMapping("/add")
    public R addPost(@RequestBody Forum forum){
        return forumService.addPost(forum);
    }

    //获取帖子列表
    @GetMapping("/getList")
    public R getForumList(Integer page,
                          Integer pageSize,
                          String postTitle,
                          Integer postStatus,
                          Long userId){
        return forumService.getListPage(page,pageSize,postTitle,postStatus,userId);
    }

    //根据帖子id获取信息
    @GetMapping("/details/{postId}")
    public R getPostInfoDetails(@PathVariable Long postId){
        return  forumService.getPostDetails(postId);
    }

    //修改某个帖子的状态
    @PostMapping("/editStatus")
    public R editStatus(Long postId,Integer postStatus){
        return forumService.setPostStatus(postId,postStatus);
    }

    //获取某个用户帖子列表
    @GetMapping("/userList")
    public R getUserForumList(Long userId){
        return forumService.getUserForumList(userId);
    }

    //删除帖子
    @DeleteMapping("/delete/{postId}")
    public R deleteForumItem(@PathVariable Integer postId){
      return   forumService.deletePostItem(postId);

    }
}
